package com.xqboss.apps.domain.nft;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.xqboss.apps.dto.nft.ChainLevelDTO;
import com.xqboss.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * <p>
 *
 * </p>
 *
 * @author HaoLun
 * @since 2022-11-18
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value = "ChainSeries对象", description = "宠物系列")
public class ChainSeries extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "系列名称")
    private String seriesName;

//    @ApiModelProperty(value = "系列分类")
//    @TableField(exist = false)
//    private List<List<ChainSeriesCategory>> seriesCategory;

    @ApiModelProperty(value = "等级ID")
    private String seriesLevels;

    @ApiModelProperty(value = "等级ID")
    private String seriesUnitCounts;

    @ApiModelProperty(value = "模板ID")
    private Integer templateId;

    @ApiModelProperty(value = "系列总量")
    @TableField(exist = false)
    private Integer seriesTotalNum = 0;

    @ApiModelProperty(value = "生成总量")
    @TableField(exist = false)
    private Integer generateTotalNum = 0;

    @ApiModelProperty(value = "已绑定总量")
    @TableField(exist = false)
    private Integer bindTotalNum = 0;

    @ApiModelProperty(value = "藏品等级数")
    @TableField(exist = false)
    private Integer levelTotalNum = 0;

    @TableField(exist = false)
    private String img;

    @ApiModelProperty(value = "种族 0其他 蟾蜍: 1巨龙2魔龙 3圣龙 / 五行圣兽: 4金 5木 6水 7火 8土")
    private Integer raceId;

    @ApiModelProperty(value = "宠物派系 1蟾蜍 2五行圣兽")
    private Integer factionsId;

    public enum ChainLevelEnum {

        等级1(1, "UR"),

        等级2(2, "SSR"),
        等级3(3, "SSS"),
        等级4(4, "SS"),
        等级5(5, "S"),
        等级6(6, "R");


        private int value;

        private String levelName;

        ChainLevelEnum(int value, String levelName) {
            this.value = value;
            this.levelName = levelName;
        }

        public int getValue() {
            return value;
        }

        public String getLevelName() {
            return levelName;
        }

        public static List<ChainLevelDTO> getValues() {
            List<ChainLevelEnum> chainLevelEnums = Stream.of(ChainLevelEnum.values()).collect(Collectors.toList());
            List<ChainLevelDTO> chainLevelDTOS = new ArrayList<>();
            chainLevelEnums.forEach(chainLevelEnum -> {
                ChainLevelDTO chainLevelDTO = new ChainLevelDTO();
                chainLevelDTO.setLevelId(chainLevelEnum.getValue());
                chainLevelDTO.setLevelName(chainLevelDTO.getLevelName());
                chainLevelDTOS.add(chainLevelDTO);
            });
            return chainLevelDTOS;
        }

        public void setValue(int value) {
            this.value = value;
        }


        public static ChainLevelEnum toLevel(int value) {
            return Stream.of(ChainLevelEnum.values())
                    .filter(c -> c.value == value)
                    .findAny()
                    .orElse(null);
        }
    }


    public enum ChainFactionsEnum {

        SCX(1, "生产系");


        private int value;

        private String factionsName;

        ChainFactionsEnum(int value, String factionsName) {
            this.value = value;
            this.factionsName = factionsName;
        }

        public int getValue() {
            return value;
        }

        public String getFactionsName() {
            return factionsName;
        }


        public void setValue(int value) {
            this.value = value;
        }


        public static ChainFactionsEnum toFactionsName(int value) {
            return Stream.of(ChainFactionsEnum.values())
                    .filter(c -> c.value == value)
                    .findAny()
                    .orElse(null);
        }
    }


    public enum ChainRaceEnum {

        QT(0, "其他"),
        JL(1, "巨龙"),
        ML(2, "魔龙"),
        SL(3, "圣龙"),
        YL(4, "幼龙"),
        ;


        private int value;

        private String raceName;

        ChainRaceEnum(int value, String raceName) {
            this.value = value;
            this.raceName = raceName;
        }

        public int getValue() {
            return value;
        }

        public String getRaceName() {
            return raceName;
        }


        public void setValue(int value) {
            this.value = value;
        }


        public static ChainRaceEnum toRaceName(int value) {
            return Stream.of(ChainRaceEnum.values())
                    .filter(c -> c.value == value)
                    .findAny()
                    .orElse(null);
        }
    }

}
